﻿using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(USTimelineProperty))]
public class USTimelinePropertyEditor : USTimelineBaseEditor
{
    private USAnimationCurveEditor curveEditor = new USAnimationCurveEditor();
    private USTimelineBase edittingTimeline;
    public bool expanded;
    private Dictionary<object, bool> expandedProperties = new Dictionary<object, bool>();
    private bool hasRegisteredForUndoRedo;
    public float noneExpandedHeight = 16f;
    private float prevRunTime;
    private float propertyHeight = 13f;
    [SerializeField]
    private USPropertyInfo selectedProperty;
    private float totalHeight = 20f;

    private void AddKeyframe(USTimelineProperty propertyTimeline, USPropertyInfo usPropertyInfo)
    {
        float runningTime = propertyTimeline.Sequence.RunningTime;
        object ourValue = null;
        if (usPropertyInfo.fieldInfo != null)
        {
            ourValue = usPropertyInfo.fieldInfo.GetValue(usPropertyInfo.component);
        }
        if (usPropertyInfo.propertyInfo != null)
        {
            ourValue = usPropertyInfo.propertyInfo.GetValue(usPropertyInfo.component, null);
        }
        usPropertyInfo.AddKeyframe(ourValue, runningTime, this.curveEditor.AutoSmoothTangents);
    }

    private void AddProperty(USTimelineProperty property, SerializedProperty serializedProperty, Component animatedComponent)
    {
    }

    public override void AddRightClickOptions(GenericMenu contextMenu, Vector2 mousePosition)
    {
        if (this.expanded)
        {
            this.curveEditor.AddRightClickOptions(contextMenu, mousePosition);
        }
    }

    private bool CheckExpanded(USTimelineProperty propertyTimeline)
    {
        string key = propertyTimeline.name + "-" + propertyTimeline.AffectedObject.name + "-expanded";
        if (!EditorPrefs.HasKey(key))
        {
            bool flag = false;
            EditorPrefs.SetBool(key, flag);
        }
        return EditorPrefs.GetBool(key);
    }

    private bool CheckExpandedProperty(Component passedObject)
    {
        object[] objArray1 = new object[] { "Sequencer-", passedObject.gameObject, "-", passedObject.GetType().ToString(), "-expanded" };
        string key = string.Concat(objArray1);
        if (!this.expandedProperties.ContainsKey(passedObject))
        {
            bool @bool = false;
            if (EditorPrefs.HasKey(key))
            {
                @bool = EditorPrefs.GetBool(key);
            }
            this.expandedProperties.Add(passedObject, @bool);
        }
        EditorPrefs.SetBool(key, this.expandedProperties[passedObject]);
        return this.expandedProperties[passedObject];
    }

    private void CheckForPropertyDifferences(USTimelineBase timeline)
    {
        USTimelineProperty propertyTimeline = timeline as USTimelineProperty;
        if (AnimationUtility.InAnimationMode() && !timeline.Sequence.IsPlaying)
        {
            foreach (USPropertyInfo info in propertyTimeline.Properties)
            {
                if ((info != null) && info.HasPropertyBeenModified(propertyTimeline.Sequence.RunningTime))
                {
                    Undo.RegisterUndo(this.selectedProperty, "添加关键帧");
                    Undo.RegisterUndo(this, "添加关键帧");
                    foreach (USInternalCurve curve in this.selectedProperty.curves)
                    {
                        Undo.RegisterUndo(curve, "添加关键帧");
                    }
                    this.AddKeyframe(propertyTimeline, info);
                }
            }
        }
    }

    private void CreateAndAddProperty(USTimelineProperty propertyTimeline, FieldInfo fieldInfo, Component propertyComponent)
    {
        Undo.RegisterUndo(propertyTimeline, "添加属性");
        Undo.RegisterUndo(this, "添加属性");
        USPropertyInfo propertyInfo = (USPropertyInfo) ScriptableObject.CreateInstance(typeof(USPropertyInfo));
        propertyInfo.fieldInfo = fieldInfo;
        propertyInfo.component = propertyComponent;
        PropertyTypeInfo mappedType = USPropertyInfo.GetMappedType(fieldInfo.FieldType);
        if (mappedType == PropertyTypeInfo.None)
        {
            Debug.LogError("不能创建属性曲线: " + fieldInfo.FieldType + "，属性类型不受支持");
        }
        else
        {
            propertyInfo.CreatePropertyInfo(mappedType);
            object ourValue = fieldInfo.GetValue(propertyComponent);
            propertyInfo.AddKeyframe(ourValue, 0f, this.curveEditor.AutoSmoothTangents);
            propertyInfo.AddKeyframe(ourValue, propertyTimeline.Sequence.Duration, this.curveEditor.AutoSmoothTangents);
            propertyTimeline.AddProperty(propertyInfo);
            this.SelectedProperty = propertyInfo;
        }
    }

    private void CreateAndAddProperty(USTimelineProperty propertyTimeline, PropertyInfo propertyInfo, Component propertyComponent)
    {
        Undo.RegisterUndo(propertyTimeline, "添加属性");
        Undo.RegisterUndo(this, "添加属性");
        USPropertyInfo info = (USPropertyInfo) ScriptableObject.CreateInstance(typeof(USPropertyInfo));
        info.propertyInfo = propertyInfo;
        info.component = propertyComponent;
        PropertyTypeInfo mappedType = USPropertyInfo.GetMappedType(propertyInfo.PropertyType);
        if (mappedType == PropertyTypeInfo.None)
        {
            Debug.LogError("不能创建属性曲线：" + propertyInfo.PropertyType + "，属性类型不受支持");
        }
        else
        {
            info.CreatePropertyInfo(mappedType);
            object ourValue = propertyInfo.GetValue(propertyComponent, null);
            info.AddKeyframe(ourValue, 0f, this.curveEditor.AutoSmoothTangents);
            info.AddKeyframe(ourValue, propertyTimeline.Sequence.Duration, this.curveEditor.AutoSmoothTangents);
            propertyTimeline.AddProperty(info);
            this.SelectedProperty = info;
        }
    }

    private int GetPropertyCountForObject(USTimelineProperty propertyTimeline)
    {
        GameObject gameObject = propertyTimeline.AffectedObject.gameObject;
        int num = 0;
        foreach (Component component in gameObject.GetComponents<Component>())
        {
            if ((component.GetType() != typeof(Behaviour)) && this.CheckExpandedProperty(component))
            {
                foreach (PropertyInfo info in component.GetType().GetProperties())
                {
                    if (!this.shouldIgnoreProperty(info, component) && (!USControl.ShowOnlyAnimated || (propertyTimeline.GetProperty(info.Name, component) != null)))
                    {
                        num++;
                    }
                }
                foreach (FieldInfo info2 in component.GetType().GetFields())
                {
                    if (!this.shouldIgnoreField(info2, component) && (!USControl.ShowOnlyAnimated || (propertyTimeline.GetProperty(info2.Name, component) != null)))
                    {
                        num++;
                    }
                }
            }
        }
        return num;
    }

    public override void GetSelectableObjectUnderPos(ref List<UnityEngine.Object> selectedObjects, Rect selectionArea)
    {
        if (this.expanded)
        {
            this.curveEditor.GetSelectableObjectUnderPos(ref selectedObjects, selectionArea, base.myArea);
        }
    }

    public override void HandleFloatingLeftClick(Transform transform, Event evt, Rect thisArea)
    {
        thisArea.x += 40f;
        thisArea.height = this.noneExpandedHeight;
        thisArea.width -= thisArea.x;
        if (thisArea.Contains(evt.mousePosition))
        {
            base.HandleFloatingLeftClick(transform, evt, thisArea);
        }
    }

    public bool IsValidType(System.Type type)
    {
        if ((((type != typeof(int)) && (type != typeof(long))) && ((type != typeof(float)) && (type != typeof(double)))) && (((type != typeof(Vector2)) && (type != typeof(Vector3))) && ((type != typeof(Color)) && (type != typeof(Quaternion)))))
        {
            return false;
        }
        return true;
    }

    private void OnEnable()
    {
        base.Setup();
        if (!this.hasRegisteredForUndoRedo)
        {
            this.hasRegisteredForUndoRedo = true;
            USControl.RegisterUndoRedo(new USControl.UndoRedoFunction(this.OnUndoRedo));
            EditorApplication.update = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(this.PropertyChangeUpdate));
        }
    }

    public override Rect OnFloatingBackground(Rect thisArea)
    {
        thisArea.height = this.myArea.height;
        GUI.Box(thisArea, string.Empty, base.defaultFloatingBackground);
        return thisArea;
    }

    public override void OnFloatingContents(Rect thisArea)
    {
        USTimelineProperty targetTimeline = base.TargetTimeline as USTimelineProperty;
        int num = 0;
        foreach (Component component in targetTimeline.AffectedObject.GetComponents<Component>())
        {
            if (!USControl.ShowOnlyAnimated || targetTimeline.HasPropertiesForComponent(component))
            {
                num++;
            }
        }
        this.totalHeight = this.noneExpandedHeight;
        this.totalHeight += this.noneExpandedHeight * num;
        this.totalHeight += (this.propertyHeight + 3f) * this.GetPropertyCountForObject(targetTimeline);
        this.totalHeight += 20f;
        thisArea.height = this.totalHeight;
        GUILayout.BeginArea(thisArea);
        EditorGUIUtility.LookLikeControls();
        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
        GUILayout.Space(13f);
        this.SetExpanded(targetTimeline, EditorGUILayout.Foldout(this.expanded, targetTimeline.name));
        GUILayout.EndHorizontal();
        EditorGUIUtility.LookLikeInspector();
        thisArea.y = 0f;
        thisArea.x = 0f;
        if (!this.expanded)
        {
            GUILayout.EndArea();
        }
        else
        {
            foreach (Component component2 in targetTimeline.AffectedObject.GetComponents<Component>())
            {
                if ((component2.GetType() != typeof(Behaviour)) && (!USControl.ShowOnlyAnimated || targetTimeline.HasPropertiesForComponent(component2)))
                {
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    GUILayout.Space(25f);
                    GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(17f), GUILayout.Height(this.noneExpandedHeight) };
                    GUILayout.Label(EditorGUIUtility.ObjectContent(component2, component2.GetType()).image, options);
                    EditorGUIUtility.LookLikeControls();
                    this.expandedProperties[component2] = EditorGUILayout.Foldout(this.CheckExpandedProperty(component2), component2.GetType().Name);
                    EditorGUIUtility.LookLikeInspector();
                    GUILayout.EndHorizontal();
                    if (this.CheckExpandedProperty(component2))
                    {
                        foreach (PropertyInfo info in component2.GetType().GetProperties())
                        {
                            if (!this.shouldIgnoreProperty(info, component2) && (!USControl.ShowOnlyAnimated || (targetTimeline.GetProperty(info.Name, component2) != null)))
                            {
                                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                                GUILayout.Space(50f);
                                if (!targetTimeline.ContainsProperty(info.Name, component2))
                                {
                                    GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(22f), GUILayout.Height(this.propertyHeight) };
                                    if (GUILayout.Button("+", optionArray2))
                                    {
                                        this.CreateAndAddProperty(targetTimeline, info, component2);
                                        this.SelectProperty(targetTimeline, info.Name, component2);
                                    }
                                }
                                else
                                {
                                    Color color = GUI.color;
                                    GUI.color = Color.red;
                                    GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(22f), GUILayout.Height(this.propertyHeight) };
                                    if (GUILayout.Button("-", optionArray3))
                                    {
                                        this.RemoveProperty(targetTimeline, info.Name, component2);
                                    }
                                    GUI.color = color;
                                }
                                GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.Height(this.propertyHeight) };
                                if (GUILayout.Button(info.Name, "label", optionArray4))
                                {
                                    this.SelectProperty(targetTimeline, info.Name, component2);
                                }
                                if ((this.selectedProperty != null) && (this.selectedProperty == targetTimeline.GetProperty(info.Name, component2)))
                                {
                                    GUIStyle style = null;
                                    GUISkin uSeqSkin = USEditorUtility.USeqSkin;
                                    if (uSeqSkin != null)
                                    {
                                        style = uSeqSkin.GetStyle("OutlinedLabel");
                                    }
                                    Rect lastRect = GUILayoutUtility.GetLastRect();
                                    lastRect.x = 0f;
                                    lastRect.width = thisArea.width;
                                    lastRect.height += 4f;
                                    if (!EditorGUIUtility.isProSkin && (style != null))
                                    {
                                        GUI.Box(lastRect, string.Empty, style);
                                    }
                                    else
                                    {
                                        GUI.Box(lastRect, string.Empty);
                                    }
                                }
                                GUILayout.EndHorizontal();
                            }
                        }
                        foreach (FieldInfo info2 in component2.GetType().GetFields())
                        {
                            if (!this.shouldIgnoreField(info2, component2) && (!USControl.ShowOnlyAnimated || (targetTimeline.GetProperty(info2.Name, component2) != null)))
                            {
                                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                                GUILayout.Space(50f);
                                if (!targetTimeline.ContainsProperty(info2.Name, component2))
                                {
                                    GUILayoutOption[] optionArray5 = new GUILayoutOption[] { GUILayout.Width(22f), GUILayout.Height(this.propertyHeight) };
                                    if (GUILayout.Button("+", optionArray5))
                                    {
                                        this.CreateAndAddProperty(targetTimeline, info2, component2);
                                        this.SelectProperty(targetTimeline, info2.Name, component2);
                                    }
                                }
                                else
                                {
                                    Color color2 = GUI.color;
                                    GUI.color = Color.red;
                                    GUILayoutOption[] optionArray6 = new GUILayoutOption[] { GUILayout.Width(22f), GUILayout.Height(this.propertyHeight) };
                                    if (GUILayout.Button("-", optionArray6))
                                    {
                                        this.RemoveProperty(targetTimeline, info2.Name, component2);
                                    }
                                    GUI.color = color2;
                                }
                                GUILayoutOption[] optionArray7 = new GUILayoutOption[] { GUILayout.Height(this.propertyHeight) };
                                if (GUILayout.Button(info2.Name, "label", optionArray7))
                                {
                                    this.SelectProperty(targetTimeline, info2.Name, component2);
                                }
                                if ((this.selectedProperty != null) && (this.selectedProperty == targetTimeline.GetProperty(info2.Name, component2)))
                                {
                                    Rect position = GUILayoutUtility.GetLastRect();
                                    position.x = 0f;
                                    position.width = thisArea.width;
                                    position.height += 4f;
                                    GUI.Box(position, string.Empty);
                                }
                                GUILayout.EndHorizontal();
                            }
                        }
                        if (this.GetPropertyCountForObject(targetTimeline) == 0)
                        {
                            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                            GUILayout.Space(45f);
                            GUILayoutOption[] optionArray8 = new GUILayoutOption[] { GUILayout.Height(this.propertyHeight) };
                            EditorGUILayout.LabelField("没有属性", optionArray8);
                            GUILayout.EndHorizontal();
                        }
                    }
                }
            }
            GUILayout.EndArea();
        }
    }

    public override void OnInspectorGUI()
    {
        base.DrawDefaultInspector();
    }

    public override void OnTimelineBackground(Rect thisArea)
    {
        thisArea.height = this.myArea.height;
        GUI.Box(thisArea, string.Empty, base.defaultTimelineBackground);
    }

    public override void OnTimelineContents(Rect thisArea)
    {
        thisArea.height = this.myArea.height;
        base.myArea = thisArea;
        USTimelineProperty targetTimeline = base.TargetTimeline as USTimelineProperty;
        this.expanded = this.CheckExpanded(targetTimeline);
        if (this.expanded && (targetTimeline.AffectedObject != null))
        {
            this.edittingTimeline = targetTimeline;
            this.curveEditor.Duration = targetTimeline.Sequence.Duration;
            foreach (USPropertyInfo info in targetTimeline.Properties)
            {
                if (info != null)
                {
                    foreach (USInternalCurve curve in info.curves)
                    {
                        curve.Duration = targetTimeline.Sequence.Duration;
                    }
                    if ((targetTimeline.AffectedObject.GetComponent(info.component.GetType()) != null) && (targetTimeline.AffectedObject.GetComponent(info.component.GetType()) != info.component))
                    {
                        info.component = targetTimeline.AffectedObject.GetComponent(info.component.GetType());
                        this.expandedProperties.Clear();
                        if ((targetTimeline.Properties.Count > 0) && (targetTimeline.Properties[0] != null))
                        {
                            this.SelectProperty(targetTimeline, targetTimeline.Properties[0].propertyName, targetTimeline.Properties[0].component);
                        }
                    }
                }
            }
            thisArea.height = this.myArea.height;
            if ((this.selectedProperty == null) || !targetTimeline.ContainsProperty(this.selectedProperty.propertyName, this.selectedProperty.component))
            {
                if ((targetTimeline.Properties.Count > 0) && (targetTimeline.Properties[0] != null))
                {
                    this.SelectProperty(targetTimeline, targetTimeline.Properties[0].propertyName, targetTimeline.Properties[0].component);
                }
                if ((this.selectedProperty == null) || !targetTimeline.ContainsProperty(this.selectedProperty.propertyName, this.selectedProperty.component))
                {
                    GUI.Label(thisArea, "没有动画属性");
                    return;
                }
            }
            Color color = GUI.color;
            if (!EditorGUIUtility.isProSkin)
            {
                GUI.color = new Color(0.25f, 0.25f, 0.25f, 1f);
            }
            GUILayout.BeginArea(thisArea, string.Empty, "box");
            GUI.color = color;
            Rect area = new Rect(0f, 0f, thisArea.width, thisArea.height);
            this.curveEditor.OnGUI(area, base.myArea);
            area.x += 40f;
            if (this.selectedProperty != null)
            {
                GUIStyle style = null;
                GUISkin uSeqSkin = USEditorUtility.USeqSkin;
                if (uSeqSkin != null)
                {
                    style = uSeqSkin.GetStyle("AnimCurveLabel");
                }
                string str = this.selectedProperty.component.GetType().ToString();
                string fieldName = "没有属性";
                if ((this.selectedProperty.fieldName != null) && (this.selectedProperty.fieldName.Length > 0))
                {
                    fieldName = this.selectedProperty.fieldName;
                }
                if ((this.selectedProperty.propertyName != null) && (this.selectedProperty.propertyName.Length > 0))
                {
                    fieldName = this.selectedProperty.propertyName;
                }
                GUI.Label(area, str + "--" + fieldName, style);
            }
            GUILayout.EndArea();
        }
    }

    private void OnUndoRedo()
    {
        if (this.edittingTimeline != null)
        {
            if (this.selectedProperty != null)
            {
                this.curveEditor.SetEdittingProperty(this.selectedProperty);
            }
            USTimelineProperty edittingTimeline = this.edittingTimeline as USTimelineProperty;
            if (edittingTimeline != null)
            {
                foreach (USPropertyInfo info in edittingTimeline.Properties)
                {
                    if ((info != null) && (edittingTimeline.Sequence != null))
                    {
                        info.SetValue(edittingTimeline.Sequence.RunningTime);
                    }
                }
            }
        }
    }

    public override void ProcessRemoveObject()
    {
        this.curveEditor.ProcessRemoveObject();
    }

    private void PropertyChangeUpdate()
    {
        if (this.edittingTimeline != null)
        {
            USTimelineProperty edittingTimeline = this.edittingTimeline as USTimelineProperty;
            if (edittingTimeline != null)
            {
                if (this.edittingTimeline.Sequence.RunningTime != this.prevRunTime)
                {
                    this.prevRunTime = this.edittingTimeline.Sequence.RunningTime;
                }
                else
                {
                    foreach (USPropertyInfo info in edittingTimeline.Properties)
                    {
                        bool flag = false;
                        foreach (USInternalCurve curve in info.curves)
                        {
                            if (curve.HasBeenModified)
                            {
                                flag = true;
                            }
                        }
                        if (flag)
                        {
                            info.SetValue(this.edittingTimeline.Sequence.RunningTime);
                        }
                        foreach (USInternalCurve curve2 in info.curves)
                        {
                            curve2.HasBeenModified = false;
                        }
                    }
                    this.CheckForPropertyDifferences(this.edittingTimeline);
                }
            }
        }
    }

    private void RemoveProperty(USTimelineProperty propertyTimeline, string propertyInfoName, Component propertyComponent)
    {
        USPropertyInfo property = propertyTimeline.GetProperty(propertyInfoName, propertyComponent);
        Undo.RegisterUndo(this, "删除属性");
        if (((this.selectedProperty != null) && ((this.selectedProperty.propertyName == propertyInfoName) || (this.selectedProperty.fieldName == propertyInfoName))) && (this.selectedProperty.component == propertyComponent))
        {
            this.selectedProperty = null;
        }
        Undo.RegisterSceneUndo("删除属性");
        property.SetValue(0f);
        propertyTimeline.RemoveProperty(property);
        UnityEngine.Object.DestroyImmediate(property);
    }

    [DrawGizmo(GizmoType.NotSelected)]
    private static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType)
    {
        USTimelineBase component = objectTransform.GetComponent<USTimelineBase>();
        if ((component != null) && (component.Sequence != null))
        {
            USTimelineProperty property = component as USTimelineProperty;
            if (property != null)
            {
                USTimelinePropertyEditor key = EditorTimelineObjectMap.GetKey(component) as USTimelinePropertyEditor;
                if ((key != null) && key.expanded)
                {
                    USPropertyInfo info = null;
                    foreach (USPropertyInfo info2 in property.Properties)
                    {
                        if ((info2 != null) && ((info2.component.GetType() == typeof(Transform)) && ((info2.propertyName == "position") || (info2.propertyName == "localPosition"))))
                        {
                            info = info2;
                        }
                    }
                    if ((info != null) && (component.Sequence.Duration > 0f))
                    {
                        int num = 20;
                        int num2 = num * Mathf.CeilToInt(component.Sequence.Duration);
                        num2 = Mathf.Clamp(num2, 2, 0x9c4);
                        float num3 = component.Sequence.Duration / ((float) num2);
                        for (int i = 0; i < (num2 - 1); i++)
                        {
                            Vector3 valueForTime = (Vector3) info.GetValueForTime(i * num3);
                            Vector3 to = (Vector3) info.GetValueForTime((i + 1) * num3);
                            Gizmos.DrawLine(valueForTime, to);
                        }
                    }
                }
            }
        }
    }

    private void SelectProperty(USTimelineProperty affectedProperty, string propertyName, Component component)
    {
        USPropertyInfo property = affectedProperty.GetProperty(propertyName, component);
        if (property != null)
        {
            this.SelectedProperty = property;
        }
    }

    private void SetExpanded(USTimelineProperty propertyTimeline, bool expanded)
    {
        string key = propertyTimeline.name + "-" + propertyTimeline.AffectedObject.name + "-expanded";
        if (!expanded)
        {
            this.myArea.height = this.noneExpandedHeight;
        }
        else
        {
            this.myArea.height = this.totalHeight;
        }
        EditorPrefs.SetBool(key, expanded);
    }

    public bool shouldIgnoreField(FieldInfo field, Component component)
    {
        object obj2;
        if (field.FieldType == typeof(HideFlags))
        {
            return true;
        }
        if (!this.IsValidType(field.FieldType))
        {
            return true;
        }
        try
        {
            obj2 = field.GetValue(component);
        }
        catch
        {
            return true;
        }
        return (obj2 == null);
    }

    public bool shouldIgnoreProperty(PropertyInfo property, Component component)
    {
        object obj2;
        foreach (Attribute attribute in Attribute.GetCustomAttributes(property))
        {
            if (attribute.GetType() == typeof(ObsoleteAttribute))
            {
                return true;
            }
        }
        if ((((component.GetType() == typeof(Transform)) && (property.Name != "position")) && ((property.Name != "rotation") && (property.Name != "scale"))) && (((property.Name != "localPosition") && (property.Name != "localRotation")) && (property.Name != "localScale")))
        {
            return true;
        }
        if (property.PropertyType == typeof(HideFlags))
        {
            return true;
        }
        if (!property.CanWrite)
        {
            return true;
        }
        if (!this.IsValidType(property.PropertyType))
        {
            return true;
        }
        try
        {
            obj2 = property.GetValue(component, null);
        }
        catch
        {
            return true;
        }
        return (obj2 == null);
    }

    public USPropertyInfo SelectedProperty
    {
        get
        {
            return this.selectedProperty;
        }
        set
        {
            this.selectedProperty = value;
            if (this.selectedProperty != null)
            {
                this.curveEditor.SetEdittingProperty(this.selectedProperty);
                Selection.activeTransform = this.edittingTimeline.AffectedObject.transform;
            }
        }
    }
}

